package com.ersin.sistek.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.ForeignKey;

@Entity
@Table(name = "SIPARIS_DETAY", catalog = "testdb")
public class SiparisDetayBean extends BaseBean implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@ManyToOne
	@JoinColumn(name = "SIPARIS_ID", nullable = false)
	@ForeignKey(name = "SIPARIS_ID_FK")
	private SiparisBean siparisId;

	@ManyToOne
	@JoinColumn(name = "MALZEME_ID", nullable = false)
	@ForeignKey(name = "MALZEME_ID_FK")
	private MalzemeBean malzemeId;

	@Column(name = "MIKTAR")
	private int miktar;

	@Column(name = "SIPARIS_DETAY_ACIKLAMA", length = 60)
	private String siparisDetayAciklama;

	public SiparisBean getSiparisId() {
		return siparisId;
	}

	public void setSiparisId(SiparisBean siparisId) {
		this.siparisId = siparisId;
	}

	public MalzemeBean getMalzemeId() {
		return malzemeId;
	}

	public void setMalzemeId(MalzemeBean malzemeId) {
		this.malzemeId = malzemeId;
	}

	public int getMiktar() {
		return miktar;
	}

	public void setMiktar(int miktar) {
		this.miktar = miktar;
	}

	public String getSiparisDetayAciklama() {
		return siparisDetayAciklama;
	}

	public void setSiparisDetayAciklama(String siparisDetayAciklama) {
		this.siparisDetayAciklama = siparisDetayAciklama;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((malzemeId == null) ? 0 : malzemeId.hashCode());
		result = prime * result + miktar;
		result = prime
				* result
				+ ((siparisDetayAciklama == null) ? 0 : siparisDetayAciklama
						.hashCode());
		result = prime * result
				+ ((siparisId == null) ? 0 : siparisId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SiparisDetayBean other = (SiparisDetayBean) obj;

		if (malzemeId == null) {
			if (other.malzemeId != null)
				return false;
		} else if (!malzemeId.equals(other.malzemeId))
			return false;
		if (miktar != other.miktar)
			return false;
		if (siparisDetayAciklama == null) {
			if (other.siparisDetayAciklama != null)
				return false;
		} else if (!siparisDetayAciklama.equals(other.siparisDetayAciklama))
			return false;
		if (siparisId == null) {
			if (other.siparisId != null)
				return false;
		} else if (!siparisId.equals(other.siparisId))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "SiparisDetayBean [ siparisId=" + siparisId + ", malzemeId="
				+ malzemeId + ", miktar=" + miktar + ", siparisDetayAciklama="
				+ siparisDetayAciklama + "]";
	}

}
